package com.kongxx.struts2study.jfreechart.web.action;

import com.opensymphony.xwork2.ActionSupport;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;

public class MyLineChart1Action extends ActionSupport {

	private JFreeChart chart;

	public String execute() throws Exception {
		DefaultCategoryDataset dataset = new DefaultCategoryDataset();
		dataset.addValue(21.0D, "Series 1", "Category 1");
		dataset.addValue(50.0D, "Series 1", "Category 2");
		dataset.addValue(152.0D, "Series 1", "Category 3");
		dataset.addValue(184.0D, "Series 1", "Category 4");
		dataset.addValue(299.0D, "Series 1", "Category 5");
		dataset.addValue(275.0D, "Series 2", "Category 1");
		dataset.addValue(121.0D, "Series 2", "Category 2");
		dataset.addValue(98.0D, "Series 2", "Category 3");
		dataset.addValue(103.0D, "Series 2", "Category 4");
		dataset.addValue(210.0D, "Series 2", "Category 5");
		dataset.addValue(198.0D, "Series 3", "Category 1");
		dataset.addValue(165.0D, "Series 3", "Category 2");
		dataset.addValue(55.0D, "Series 3", "Category 3");
		dataset.addValue(34.0D, "Series 3", "Category 4");
		dataset.addValue(77.0D, "Series 3", "Category 5");
		chart = ChartFactory.createLineChart("Line Chart Demo", "Category", "Count", dataset, PlotOrientation.VERTICAL, true, true, false);
		//chart = ChartFactory.createLineChart("Line Chart Demo", "Category", "Count", dataset, PlotOrientation.HORIZONTAL, true, true, false);
		return SUCCESS;
	}

	public JFreeChart getChart() {
		return chart;
	}

	public void setChart(JFreeChart chart) {
		this.chart = chart;
	}
}